<template>
  <div class="lpl">
    <div>
      <Fanhui />
    </div>

    <div>
      <van-form @submit="onSubmit">
        <van-field
          name="mobile"
          label="手机号"
          placeholder="手机号"
          @touchstart.native.stop="show = true"
          readonly
          clickable
          :value="value"
          :rules="[{ required: true, pattern, message: '请输入正确手机号' }]"
        />

        <van-number-keyboard
          v-model="value"
          :show="show"
          :maxlength="11"
          @blur="show = false"
        />

        <van-field
          v-model="password"
          type="password"
          name="password"
          label="密码"
          placeholder="密码"
          :rules="[
            { required: true, validator, message: '请填写正确密码,最少六位' },
          ]"
        />
         <van-field
          v-model="password"
          type="text"
          name="name"
          label="用户名"
          placeholder="用户名"
          :rules="[
            { required: true, validator, message: '请填写正确用户名,最少三个汉字' },
          ]"
        />
        
        <div style="margin: 16px">
          <van-button round block type="info" native-type="submit"
            >注册</van-button
          >
        </div>
      </van-form>
    </div>
  </div>
</template>

<script>
import Fanhui from "@/views/Center/fanhui.vue";
import Vue from "vue";
import { Form, Field, Button } from "vant";
import { NumberKeyboard, Toast } from "vant";
Vue.use(Form);
Vue.use(Field);
Vue.use(Button);
Vue.use(Toast);
Vue.use(NumberKeyboard);

export default {
  data() {
    return {
      username: "",
      password: "",
      show: false,
      value: "",

      pattern: /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/,
    };
  },
  components: {
    Fanhui,
  },
  methods: {
    validator(val) {
      return /^[0-9]{6,18}$/.test(val);
    },
    onSubmit(values) {
      console.log("submit", values);
    },
  },
  created() {
    this.$store.commit("setIsShow", false);
  },

  mounted() {},
  beforeDestroy() {
    this.$store.commit("setIsShow", true);
  },
};
</script>

<style scoped>
.van-form {
  margin-top: 200px;
}
.lpl {
  height: 100%;
  width: 100%;
}
.van-button--info {
  background-color: #ff5000;
  border: 1px solid #fff;
}
</style>